import { ChessType } from "../types/enums";
import "./ChessComp.css";

interface IProps {
  type: ChessType;
  onClick?: () => void;
}

export const ChessComp: React.FC<IProps> = ({ type, onClick }: IProps) => {
  let chess = null;
  if (type === ChessType.red) {
    chess = <div className="red chess-item"></div>;
  } else if (type === ChessType.black) {
    chess = <div className="black chess-item"></div>;
  }

  return (
    <div
      className="chess"
      onClick={() => {
        if (type === ChessType.none) {
          onClick?.();
        }
      }}
    >
      {chess}
    </div>
  );
};
